{
 open Parser
 let string_chars s = String.sub s 1 ((String.length s)-2)
}

let s = ['a'-'z']+ ('_' ['a'-'z']+)? 

rule token = parse
  | '('                                 { LPA }
  | ')'                                 { RPA }
  | "true" | "false"                    { BOOL (if (Lexing.lexeme lexbuf) = "true" then true else false) }
  | '='                                 { ASSIGN  }
  | '+'                                 { ADD }
  | '-'                                 { REM }
  | '*'                                 { MUL }
  | '/'                                 { DIV }
  | "^"                                 { POW }
  | "++"                                { CONCAT }
  | "&&"                                { AND }
  | "||"                                { OR }
  | "<" | ">" | ">=" | "<="  | "==" | "%"    { OP (Lexing.lexeme lexbuf) }
  | "if"                                { IF }
  | "then"                              { THEN }
  | "else"                              { ELSE }
  | '"' [^ '"']* '"'                    { STRING (string_chars (Lexing.lexeme lexbuf)) }
  | ['0'-'9']+ ('.' ['0'-'9']+)?        { NUM (Lexing.lexeme lexbuf) }
  | s                                   { FUN (Lexing.lexeme lexbuf) }
  | '\n'                                { Lexing.new_line lexbuf; token lexbuf }
  | ';'                                 { STOP }
  | '.'                                 { FH }
  | _                                   { token lexbuf }
  | eof                                 { EOF }
